package com.itheima.controller;

import com.itheima.common.Code;
import com.itheima.common.MessageConstant;
import com.itheima.common.Result;
import com.itheima.entity.Category;
import com.itheima.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
*@author: lzl
*@description:菜品、套餐分类管理-控制器
*@date:Acer
*/

@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    private CategoryService categoryService;

    /**
     * 获取菜品分类列表数据
     * @param type
     * @return
     */
    @GetMapping("/list")
    public Result findAll(@RequestParam(value = "type",required = false)Integer type){
        List<Category> categoryList = categoryService.findAll(type);
        return new Result(Code.OK,MessageConstant.CAT_GET_SUCCESS,categoryList);
    }


}
